﻿//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------

using GameFramework.DataTable;
using UnityGameFramework.Runtime;

namespace Adventure
{
    public class PlayerData
    {
        private int maxLevelCount = 10;

        public string User { set; get; }

        public string Password { set; get; }

        public string HeadString { set; get; }


        private int currentHP;

        /// <summary>
        /// 当前生命值
        /// </summary>
        public int CurrentHP
        {
            get
            {
                int hp = GameEntry.DataTable.GetDRPlayer(PlayerId).MaxHP;
                if (currentHP >= hp)
                {
                    currentHP = hp;
                }
                return currentHP;
            }
            set
            {
                currentHP = value;
            }
        }

        private int currentEXP;

        /// <summary>
        /// 当前经验值
        /// </summary>
        public int CurrentEXP
        {
            get
            {
                int exp = GameEntry.DataTable.GetDRPlayer(PlayerId).MaxEXP;

                if (currentEXP >= exp)
                {
                    currentEXP = 0;
                    PlayerId++;

                    currentHP = GameEntry.DataTable.GetDRPlayer(PlayerId).MaxHP;
                }

                return currentEXP;
            }
            set
            {
                currentEXP = value;
            }
        }

        private int playerId;


        /// <summary>
        /// 玩家配置表（默认1级）
        /// </summary>
        public int PlayerId
        {
            get;

            set;
            
        }
    }
}
